<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Get Fitbit Device Data | Fitbitter</title>
    <meta name="generator" content="VuePress 1.8.2">
    
    <meta name="description" content="Fitbitter is a Flutter package that makes your life easier when dealing with Fitbit Web APIs.">
    <meta name="theme-color" content="#ff0000">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    
    <link rel="preload" href="/fitbitter/assets/css/0.styles.c96f97f1.css" as="style"><link rel="preload" href="/fitbitter/assets/js/app.411a122d.js" as="script"><link rel="preload" href="/fitbitter/assets/js/2.bc2acf6f.js" as="script"><link rel="preload" href="/fitbitter/assets/js/15.e9e9cac7.js" as="script"><link rel="prefetch" href="/fitbitter/assets/js/10.20013ba3.js"><link rel="prefetch" href="/fitbitter/assets/js/11.ac5d2caa.js"><link rel="prefetch" href="/fitbitter/assets/js/12.ed683bfb.js"><link rel="prefetch" href="/fitbitter/assets/js/13.4b8c0fe9.js"><link rel="prefetch" href="/fitbitter/assets/js/14.aacddd76.js"><link rel="prefetch" href="/fitbitter/assets/js/16.26f65e66.js"><link rel="prefetch" href="/fitbitter/assets/js/17.0ae95c9b.js"><link rel="prefetch" href="/fitbitter/assets/js/18.bd737b8f.js"><link rel="prefetch" href="/fitbitter/assets/js/19.378f9484.js"><link rel="prefetch" href="/fitbitter/assets/js/20.4703791f.js"><link rel="prefetch" href="/fitbitter/assets/js/3.2053bcf9.js"><link rel="prefetch" href="/fitbitter/assets/js/4.849471b2.js"><link rel="prefetch" href="/fitbitter/assets/js/5.a9d530e8.js"><link rel="prefetch" href="/fitbitter/assets/js/6.3d83467c.js"><link rel="prefetch" href="/fitbitter/assets/js/7.1fb23724.js"><link rel="prefetch" href="/fitbitter/assets/js/8.e7d2dab8.js"><link rel="prefetch" href="/fitbitter/assets/js/9.8c8180fb.js">
    <link rel="stylesheet" href="/fitbitter/assets/css/0.styles.c96f97f1.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/fitbitter/" class="home-link router-link-active"><!----> <span class="site-name">Fitbitter</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/fitbitter/getstarted/" class="nav-link">
  Get Started
</a></div><div class="nav-item"><a href="/fitbitter/guides/" class="nav-link router-link-active">
  Guides
</a></div><div class="nav-item"><a href="https://github.com/gcappon/fitbitter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://pub.dev/packages/fitbitter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Pub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://pub.dev/documentation/fitbitter/latest/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  API Docs
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/fitbitter/getstarted/" class="nav-link">
  Get Started
</a></div><div class="nav-item"><a href="/fitbitter/guides/" class="nav-link router-link-active">
  Guides
</a></div><div class="nav-item"><a href="https://github.com/gcappon/fitbitter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://pub.dev/packages/fitbitter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Pub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://pub.dev/documentation/fitbitter/latest/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  API Docs
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Guides</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/fitbitter/guides/fitbitAccountData.html" class="sidebar-link">Get Fitbit Account Data</a></li><li><a href="/fitbitter/guides/authorization.html" class="sidebar-link">Authorization</a></li><li><a href="/fitbitter/guides/activityData.html" class="sidebar-link">Get Activity Data</a></li><li><a href="/fitbitter/guides/activityTimeSeriesData.html" class="sidebar-link">Get Activity Timeseries Data</a></li><li><a href="/fitbitter/guides/deviceData.html" aria-current="page" class="active sidebar-link">Get Fitbit Device Data</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/fitbitter/guides/deviceData.html#get-fitbit-device-data" class="sidebar-link">Get Fitbit Device Data</a></li></ul></li><li><a href="/fitbitter/guides/heartData.html" class="sidebar-link">Get Heart Data</a></li><li><a href="/fitbitter/guides/sleepData.html" class="sidebar-link">Get Sleep Data</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="get-fitbit-device-data"><a href="#get-fitbit-device-data" class="header-anchor">#</a> Get Fitbit Device Data</h2> <div class="custom-block tip"><p class="custom-block-title">TIP</p> <p>This guide assumes that your app has already been authorized and the snippet of code that I will show you can access to the Fitbit user id, here called <code>userID</code>, the Fitbit OAuth 2.0 client ID, here called <code>clientID</code>, and the Fitbit client secret, here called <code>clientSecret</code>.</p></div> <p>Information about the user's Fitbit Device data can be obtained in three steps</p> <h3 id="step-1-instanciate-a-manager"><a href="#step-1-instanciate-a-manager" class="header-anchor">#</a> Step 1: Instanciate a manager</h3> <p>First, you need to instanciate a <code>FitbitDeviceDataManager</code></p> <div class="language-dart extra-class"><pre class="language-dart"><code>    FitbitDeviceDataManager fitbitDeviceDataManager <span class="token operator">=</span> <span class="token function">FitbitDeviceDataManager</span><span class="token punctuation">(</span>
        clientID<span class="token punctuation">:</span> <span class="token string">'&lt;OAuth 2.0 Client ID&gt;'</span><span class="token punctuation">,</span>
        clientSecret<span class="token punctuation">:</span> <span class="token string">'&lt;Client Secret&gt;'</span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><h3 id="step-2-create-the-request-url"><a href="#step-2-create-the-request-url" class="header-anchor">#</a> Step 2: Create the request url</h3> <p>Then, you have to create a url object, <code>FitbitDeviceAPIURL</code> as</p> <div class="language-dart extra-class"><pre class="language-dart"><code>    FitbitDeviceAPIURL fitbitDeviceApiUrl <span class="token operator">=</span> FitbitDeviceAPIURL<span class="token punctuation">.</span><span class="token function">withUserID</span><span class="token punctuation">(</span>userID<span class="token punctuation">:</span> userID<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><h3 id="step-3-get-the-data"><a href="#step-3-get-the-data" class="header-anchor">#</a> Step 3: Get the data</h3> <p>Finally you can obtain the Fitbit Device data using</p> <div class="language-dart extra-class"><pre class="language-dart"><code>    List<span class="token operator">&lt;</span>FitbitDeviceData<span class="token operator">&gt;</span> fitbitDeviceData <span class="token operator">=</span> <span class="token keyword">await</span> fitbitDeviceDataManager<span class="token punctuation">.</span><span class="token function">fetch</span><span class="token punctuation">(</span>fitbitDeviceApiUrl<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/fitbitter/guides/activityTimeSeriesData.html" class="prev">
        Get Activity Timeseries Data
      </a></span> <span class="next"><a href="/fitbitter/guides/heartData.html">
        Get Heart Data
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/fitbitter/assets/js/app.411a122d.js" defer></script><script src="/fitbitter/assets/js/2.bc2acf6f.js" defer></script><script src="/fitbitter/assets/js/15.e9e9cac7.js" defer></script>
  </body>
</html>
